/**
 * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
 */
// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作
const install = (Vue, vm) => {

	// 参数配置对象
	const config = vm.vuex_config;

	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		// 基础服务：登录登出、身份信息、菜单授权、切换系统、字典数据等
		lang: (params = {}) => vm.$u.get('/lang/' + params.lang),
		index: (params = {}) => vm.$u.get(config.adminPath + '/mobile/index', params),
		getUserInfo: (params = {}) => vm.$u.get(config.adminPath + '/mobile/user/getUserInfo', params),
		login: (params = {}) => vm.$u.post(config.adminPath + '/login', params),
		logout: (params = {}) => vm.$u.post(config.adminPath + '/logout', params),
		sendCode: (params = {}) => vm.$u.post(config.adminPath + '/mobile/login/sendCode', params),
		registerUser: (params = {}) => vm.$u.post(config.adminPath + '/mobile/user/registerUser', params),

		/**
		 * 系统设置API
		 */
		//获取工序清单
		getProcessList: (params = {}) => vm.$u.get(config.adminPath + '/mes/pro/releaseOrder/listByProcess',
			params),
		getRecipe: (params = {}) => vm.$u.get(config.adminPath + '/mes/pro/processProduct/list', params),
		getparameterItem: (params = {}) => vm.$u.get(config.adminPath + '/mes/pro/parameterItem/list', params),
		getbom: (params = {}) => vm.$u.get(config.adminPath + '/mes/md/bom/list', params),
		getstepimage: (id) => vm.$u.get(config.adminPath + '/mes/pro/process/' + id),
		getstep: (params = {}) => vm.$u.get(config.adminPath + '/mes/pro/step/list', params),
		listByStepTypeName: (params = {}) => vm.$u.get(config.adminPath + '/mes/pro/step/listByStepTypeName',
			params),
		listMenu: (params = {}) => vm.$u.get(config.adminPath + '/mes/pro/process/list', params),
		/**
		 * 生产管理相关API		
		 **/
		//获取当前工作站的生产任务
		getTaskList: (params = {}) => vm.$u.get(config.adminPath + '/mobile/pro/protask/getTaskList', params),
		//根据任务ID获取任务详情
		getTaskInfo: (params = {}) => vm.$u.get(config.adminPath + '/mobile/pro/protask/' + params.taskId),
		//修改任务状态
		changeStatus: (params = {}) => vm.$u.post(config.adminPath + '/mobile/pro/protask/change', params),
		//生产报工
		feedback: (params = {}) => vm.$u.post(config.adminPath + '/mobile/pro/protask/feedback', params),


		/**
		 * 工艺工序相关API
		 */
		getProcessInfo: (params = {}) => vm.$u.get(config.adminPath + '/mobile/pro/process/' + params
			.processId),
		//获取当前产品的SOP
		getSopList: (params = {}) => vm.$u.get(config.adminPath + '/mobile/pro/taskissue/getSopList', params),
		//生产混料
		addIssue: (params = {}) => vm.$u.post(config.adminPath + '/mobile/pro/taskissue/add', params),
		//整个领料单投料
		addholeIssue: (params = {}) => vm.$u.post(config.adminPath + '/mobile/pro/taskissue/addIssue', params),
		//删除投料信息
		removeTaskIssue: (params = {}) => vm.$u.post(config.adminPath + '/mobile/pro/taskissue/' + params
			.recordId),
		//获取当前工作站、当前生产任务对应的投料清单				
		getTaskIssueList: (params = {}) => vm.$u.get(config.adminPath + '/mobile/pro/taskissue/getlist',
			params),
		//查询可用的领料单
		getReserveIssue: (params = {}) => vm.$u.get(config.adminPath +
			'/mobile/pro/taskissue/getReserveIssueList', params),
		//打印流转单


		//质量相关api
		//获取当前产品、当前质检类型的质检模板行信息
		getQcTemplateLine: (params = {}) => vm.$u.get(config.adminPath + '/mobile/qc/templateindex/getLines',
			params),


		//首页相关api
		getIndexCardInfo: (params = {}) => vm.$u.get(config.adminPath + '/mobile/index/getIndexCardInfo',
			params),
		getM2mOrderFlowList: (params = {}) => vm.$u.get(config.adminPath + '/mobile/index/getM2mOrderFlowList',
			params),
		//获取卡可购买套餐包
		getM2mOrderPackageList: (params = {}) => vm.$u.get(config.adminPath +
			'/mobile/index/getM2mOrderPackageList', params),


		authInfo: (params = {}) => vm.$u.get(config.adminPath + '/authInfo', params),
		menuTree: (params = {}) => vm.$u.get(config.adminPath + '/menuTree', params),
		switchSys: (params = {}) => vm.$u.get(config.adminPath + '/switch/' + params.sysCode),
		dictData: (params = {}) => vm.$u.get(config.adminPath + '/system/dict/data/type/' + params.dictType),

		// 账号服务：验证码接口、忘记密码接口、注册账号接口等
		validCode: (params = {}) => vm.$u.getText('/captchaImage', params),
		getFpValidCode: (params = {}) => vm.$u.post('/account/getFpValidCode', params),
		savePwdByValidCode: (params = {}) => vm.$u.post('/account/savePwdByValidCode', params),
		getRegValidCode: (params = {}) => vm.$u.post('/account/getRegValidCode', params),
		saveRegByValidCode: (params = {}) => vm.$u.post('/account/saveRegByValidCode', params),

		// 获取验证码图片
		// office: {
		// 	treeData: (params = {}) => vm.$u.get(config.adminPath+'/sys/office/treeData', params),
		// },
		// APP公共服务
		upgradeCheck: () => vm.$u.post('/app/upgrade/check', {
			appCode: config.appCode,
			appVersion: config.appVersion
		}),
		commentSave: (params = {}) => vm.$u.post('/app/comment/save', params),

		// 个人信息修改
		user: {
			saveUserInfo: (params = {}) => vm.$u.post(config.adminPath + '/mobile/user/saveUserInfo', params),
			infoSavePwd: (params = {}) => vm.$u.put(config.adminPath + '/system/user/profile/updatePwd',
				params),
			infoSavePqa: (params = {}) => vm.$u.post(config.adminPath + '/sys/user/infoSavePqa', params),
		},

		// 员工用户查询
		empUser: {
			listData: (params = {}) => vm.$u.get(config.adminPath + '/sys/empUser/listData', params),
		},

		// 组织机构查询
		office: {
			treeData: (params = {}) => vm.$u.get(config.adminPath + '/sys/office/treeData', params),
		},


		// 增删改查例子
		testData: {
			form: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/form', params),
			list: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/listData', params),
			save: (params = {}) => vm.$u.postJson(config.adminPath + '/test/testData/save', params),
			disable: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/disable', params),
			enable: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/enable', params),
			delete: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/delete', params),
		},
		// 获取当前个人信息
		getUserProfile: () => vm.$u.get('/system/user/profile'),
		// 获取工作站
		getTreeselect: () => vm.$u.get('/mes/md/workstation/listAll'),
		// 获取生产队列
		listrelease: (params = {}) => vm.$u.get('/mes/pro/protask/getTaskByStationId', params),
		// 获取关键件
		getBomList: (params = {}) => vm.$u.get('/mes/pro/routeproduct/getBomListAndAttachment', params),
		// 查询工作站详细
		getWorkstation: (workstationId) => vm.$u.get(`/mes/md/workstation/${workstationId}`),
		// 完成审批单
		addFeedback: (params = {}) => vm.$u.post('/mes/pro/feedback', params),
		// 查询字典
		getDicts: (dictType) => vm.$u.get(`/system/dict/data/type/${dictType}`),
		// 获取所有产线
		getWorkLine: () => vm.$u.get(`/mes/md/workline/listAll`),
		// 发布工单列表
		listreleaseOrder: (params = {}) => vm.$u.get("/mes/pro/releaseOrder/list", params),
		// 更新生产订单状态
		updateworkOrder: (data = {}) => vm.$u.put("/mes/pro/workorder", data),
		// 获取生产订单详细信息
		getWorkOrderDetail: (workorderId) => vm.$u.get(`/mes/pro/workorder/${workorderId}`),
		// 获取工艺指导书，混料工艺卡。。。
		getRouteRequestByBomId: (bomId) => vm.$u.get(
			`/mes/pro/releaseOrder/getRouteRequestByBomId?bomId=${bomId}`),
		// 生成二维码
		getBarcode: (wmBarcode) => vm.$u.get(`/mes/wm/barcode/getBarcode?wmBarcode=${wmBarcode}`),
		// 根据编码获取字典
		genCode: (ruleCode) => vm.$u.get(`/system/dict/data/type/${ruleCode}`),
		// 根据编码规则生成编码
		getAutoCode: (ruleCode) => vm.$u.get(`/system/autocode/get/${ruleCode}`),
		// 新增异常
		addException: (data = {}) => vm.$u.post('/mes/ep/exception', data),
		// 获取工步信息
		listStepRecord: (params = {}) => vm.$u.get('/mes/pro/stepRecord/list', params),
		// 生产交班
		executeShiftHandover: (data = {}) => vm.$u.post(`/mes/pro/workorderTeam/executeShiftHandover`, data),
		// 查看历史报工数据
		getFeedbackByWorkorderId: (workorderId = '') => vm.$u.get(
			`/mes/pro/feedback/getFeedbackByWorkorderId?workorderId=${workorderId}`),
		// 生产报工
		addfeedback: (data = {}) => vm.$u.post(`/mes/pro/feedback`, data),
		// 获取所有产线当前的发布工单第一条
		getReleaseOrderByWorklineFirst: () => vm.$u.get(
			`/mes/pro/workorderTeam/getReleaseOrderByWorklineFirst`),
		// 开始生产
		startProduct: (releaseOrderId = "") => vm.$u.put(`/mes/pro/workorder/startProduct/${releaseOrderId}`),
		// 报工停产
		// stopProduct: (data = {}) => vm.$u.post(`/mes/pro/workorder/stopProduct`, data),
		stopProduct: (id) => vm.$u.post(`/mes/pro/workorder/stopProduct/${id}`),
		// 查询库存记录列表
		listWmstock: (params = {}) => vm.$u.get(`/mes/wm/wmstock/list`, params),
		// 获取所有产品
		listProduct: (params = {}) => vm.$u.get(`/mes/md/mdproduct/list`, params),
		// 获取库存产品
		stockProductList: (params = {}) => vm.$u.get(`/mes/wm/stock/list`, params),
		// 生产混料
		addtWorkorderFeed: (data = {}) => vm.$u.post(`/mes/pro/workorderFeed`, data),
		// 根据发布工单查不良品，破碎料，带回收料，混好的料
		getOtherItem: (releaseorderId) => vm.$u.get(
			`/mes/pro/routeproduct/getDefectiveProductRecoverProductIdByReleaseId/${releaseorderId}`),

		// 生产领料
		// 根据bomid获取子项
		getProductBomChildren: (query = {}) => vm.$u.get(`/mes/pro/bom/selectChildren`, query),
		addAndExecuteIssue: (data = {}) => vm.$u.post(`/mes/wm/issueheader/addAndExecute`, data),
		// 生产退料
		addAndExecuteRtIssue: (data = {}) => vm.$u.post(`/mes/wm/rtissue/addAndExecute`, data),
		// 生产调拨
		addAndExecuteAllocate: (data = {}) => vm.$u.post(`/mes/wm/stockIssue/addAndExecute`, data),
		// 产品退料
		addAndExecuteRecepu: (data = {}) => vm.$u.post(`/mes/wm/productsalse/addAndExecute`, data),
		// 提交维修单
		addRepair: (data = {}) => vm.$u.post(`/mes/dv/repair`, data),
		// 获取电量
		selectMeterData: (id) => vm.$u.get(`mes/pro/workorder/selectMeterData/${id}`),
		// 添加异常处理
		addExceptionHandling: (data = {}) => vm.$u.post(`/mes/resolution`, data),
		// 获取工艺流程
		listRouteproduct: (params = {}) => vm.$u.get(`/mes/pro/routeproduct/list`, params),
		// 查询工艺详情
		getRouteproduct: (routeId) => vm.$u.get(`/mes/pro/routeproduct/${routeId}`),
		// 异常建模列表
		listExceptionModel: (params = {}) => vm.$u.get('mes/items/list', params),
		// 开始流程
		addStart: (id, data = {}) => vm.$u.post('/workflow/process/start/' + id, data),
		//  * 存储工单报工相关信息。
		addReportData: (data = {}) => vm.$u.post('/mes/pro/reporting', data),
		// 查询已成型报工但未养护组盘的工单列表
		noCuringGroup: (params = {}) => vm.$u.get('/mes/pro/reporting/forming/noCuringGroup', params),
		// 查询养护已组盘但未拆盘的工单列表
		groupNoUngroup: (params = {}) => vm.$u.get('/mes/pro/reporting/curing/groupNoUngroup', params),
		// 查询养护已拆盘但未精整的工单列表
		ungroupNoFinishing: (params = {}) => vm.$u.get('/mes/pro/reporting/curing/ungroupNoFinishing', params),
		// 查询精整已完成但未热处理组盘的工单列表
		noHeatGroup: (params = {}) => vm.$u.get('/mes/pro/reporting/finishing/noHeatGroup', params),
		// 查询热处理已组盘但未拆盘的工单列表
		groupedNotUngrouped: (params = {}) => vm.$u.get('/mes/pro/reporting/heat/groupedNotUngrouped', params),
		// 查询热处理已拆盘的工单列表
		ungrouped: (params = {}) => vm.$u.get('/mes/pro/reporting/heat/ungrouped', params),
		// 根据托盘号拆盘
		unstackingByCode: (data = {}) => vm.$u.get('/mes/pro/reporting/unstacking?groupCodes=' + data),
		// 查询易操作的数据
		getALLreporting: (params = {}) => vm.$u.get('/mes/pro/reporting', params),
		// 撤销已操作的数据
		reportingCancel: (data = {}) => vm.$u.post('/mes/pro/reporting/cancel', data),
		// 根据发布工单id获取订单信息
		selectByReleaseOrderId: (releaseOrderId) => vm.$u.get(
			`/mes/pro/workorder/selectByReleaseOrderId?releaseOrderId=${releaseOrderId}`),
		// 添加刷卡工站
		addStation: (data = {}) => vm.$u.post('/pro/workerShift', data),
		// 查询工站信息
		workerShiftList: () => vm.$u.get('/pro/workerShift/selectByStatus'),
		// 获取工艺详情
		// getRouteproduct: (routeId) => vm.$u.get('/mes/pro/routeproduct', routeId)


	};

}

export default {
	install
}